var t = require("../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../utils/util.js")), e = getApp();

Page({
    data: {
        mobile: "",
        show: !0,
        member: [],
        memberShow: !1,
        nickname: "",
        imageUse: "",
        tapOne: !1,
        shop_id: "",
        bindStatus: !0,
        bindErrorTxt: ""
    },
    tapBtn: function() {
        this.setData({
            show: !this.data.show
        });
    },
    onLoad: function(t) {
        this.getData(), this.checkBind(), wx.setNavigationBarTitle({
            title: "债权人绑定债务人"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    init: function() {
        this.setData({
            tapOne: !1
        });
    },
    gohome: function() {
        wx.navigateTo({
            url: "/packageG/index/index"
        });
    },
    bindinp: t.default.debounce(function(t) {
        var e = t[0].detail;
        this.setData({
            mobile: e
        }), this.getUser();
    }),
    getUser: function() {
        var t = this, a = e.getNetAddresss("plugin.micro-debt.frontend.controllers.debtor.query");
        e._getNetWork({
            url: a,
            data: {
                mobile: this.data.mobile
            },
            success: function(e) {
                1 === e.data.result ? t.setData({
                    memberShow: !0,
                    member: e.data.data.member
                }) : t.setData({
                    memberShow: !1
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    bindYzUser: function() {
        var t = this;
        if (!this.data.tapOne) if (e._isTextEmpty(this.data.mobile)) wx.showToast({
            title: "请输入债务人手机号",
            duration: 1e3,
            icon: "none"
        }); else {
            this.setData({
                tapOne: !0
            });
            var a = e.getNetAddresss("plugin.micro-debt.frontend.controllers.creditor.check");
            e._getNetWork({
                url: a,
                success: function(e) {
                    1 === e.data.result && (e.data.data.bind ? wx.navigateTo({
                        url: "/packageC/microshop/micro_shop_share_home/micro_shop_share_home?shop_id=" + e.data.data.micro_id
                    }) : t.bindUser());
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    bindUser: function() {
        var t = this, a = e.getNetAddresss("plugin.micro-debt.frontend.controllers.creditor.bind");
        e._getNetWork({
            url: a,
            data: {
                mobile: this.data.mobile
            },
            success: function(e) {
                if (1 !== e.data.result) return t.setData({
                    bindStatus: !1,
                    show: !1,
                    bindErrorTxt: e.data.msg
                }), void t.init();
                t.setData({
                    show: !1,
                    bindStatus: !0
                }), setTimeout(function() {
                    wx.navigateTo({
                        url: "/packageC/microshop/micro_shop_share_home/micro_shop_share_home?shop_id=" + e.data.data.micro_id
                    });
                }, 1500);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var t = this, a = e.getNetAddresss("plugin.micro-debt.frontend.controllers.member.info");
        e._getNetWork({
            url: a,
            data: {
                mobile: this.data.mobile
            },
            success: function(e) {
                1 === e.data.result && t.setData({
                    nickname: e.data.data.member.nickname,
                    imageUse: e.data.data.member.avatar_image
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    checkBind: function() {
        var t = e.getNetAddresss("plugin.micro-debt.frontend.controllers.creditor.check");
        e._getNetWork({
            url: t,
            success: function(t) {
                1 === t.data.result && (t.data.data.bind && wx.navigateTo({
                    url: "/packageC/microshop/micro_shop_share_home/micro_shop_share_home?shop_id=" + t.data.data.micro_id
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});